{% extends 'base.html' %}

{% block title %}首页{% endblock %}

{% block left %}
    {% for post in postlist %}
        <div style="margin-left:20px">
            <h3>{{post.title}}</h3>
            <time>{{post.created|date:'Y-m-d H:i:s'}}</time>&emsp;
            <span>{{post.category.category}}：</span>

            {% for tag in post.tag.all %}
                <span>{{tag.tag}}</span>
            {% endfor %}

            <hr />
            {{post.desc}}
            <p style="margin-top:10px"><a href="/post/{{post.id}}">阅读全文</a></p>
            <img src="/static/img/line.gif" height="1px" width=100% alt="">
        </div>
    {% endfor %}

    <div class="container-fluid" style="margin-top:10px;float:left;margin-left:350px">
        <a href="/page/1">首页</a>&emsp;

        {% if postlist.has_previous %}
            <a href="/page/{{postlist.previous_page_number}}">上一页</a>&emsp;
        {% endif %}

        {% for page in page_list %}
            {% if num == page %}
                <span>{{page}}</span>&emsp;
            {% else %}
                <a href="/page/{{page}}">{{page}}</a>&emsp;
            {% endif %}
        {% endfor %}

        {% if postlist.has_next %}
            <a href="/page/{{postlist.next_page_number}}">下一页</a>
        {% endif %}

        <a href="/page/{{last_page}}">尾页</a>&emsp;
    </div>

{% endblock %}